home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 4.9 KB | 157 lines | [TEXT/MPS ] |
- //----------------------------------------------------------------------------------------
- // UDrawingEnvironment.cp
- // Copyright © 1991-96 by Apple Computer, Inc. All rights reserved.
- //----------------------------------------------------------------------------------------
-
- #ifndef __UDRAWINGENVIRONMENT__
- #include "UDrawingEnvironment.h"
- #endif
-
- // MacApp
-
- #ifndef __UMACAPPUTILITIES__
- #include "UMacAppUtilities.h"
- #endif
-
- #ifndef __USTREAM__
- #include "UStream.h"
- #endif
-
- // ANSI
-
- #ifndef __STRING__
- #include <string.h>
- #endif
-
-
- //========================================================================================
- // CLASS TDrawingEnvironment
- //========================================================================================
- #undef Inherited
- #define Inherited TObject
-
- #pragma segment MAOpen
- MA_DEFINE_CLASS_M1(TDrawingEnvironment, Inherited);
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment constructor
- //----------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- TDrawingEnvironment::TDrawingEnvironment() :
- fPenSize(1,1),
- fPenMode(patCopy),
-
- fPenPattern(qd.black),
- fForegroundColor(gRGBBlack),
- fBackgroundColor(gRGBWhite)
- {
- } // TDrawingEnvironment::TDrawingEnvironment
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment destructor
- //----------------------------------------------------------------------------------------
- #pragma segment MADestructorRes
-
- TDrawingEnvironment::~TDrawingEnvironment()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::IDrawingEnvironment:
- //----------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- void TDrawingEnvironment::IDrawingEnvironment()
- {
- this->IObject();
- } // TDrawingEnvironment::IDrawingEnvironment
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::ReadFrom:
- //----------------------------------------------------------------------------------------
- #pragma segment MAReadResource
-
- void TDrawingEnvironment::ReadFrom(TStream* aStream)
- {
- Inherited::ReadFrom(aStream);
-
- fPenSize = aStream->ReadPoint();
- fPenMode = aStream->ReadInteger();
-
- aStream->ReadBytes(&fPenPattern, sizeof(Pattern));
- aStream->ReadRGBColor(fForegroundColor);
- aStream->ReadRGBColor(fBackgroundColor);
- } // TDrawingEnvironment::ReadFrom
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::WriteTo:
- //----------------------------------------------------------------------------------------
- #pragma segment MAWriteResource
-
- void TDrawingEnvironment::WriteTo(TStream* aStream)
- {
- Inherited::WriteTo(aStream);
-
- aStream->WritePoint(fPenSize);
- aStream->WriteInteger(fPenMode);
-
- aStream->WriteBytes(&fPenPattern, sizeof(Pattern));
- aStream->WriteBytes(&fForegroundColor, sizeof(CRGBColor));
- aStream->WriteBytes(&fBackgroundColor, sizeof(CRGBColor));
- } // TDrawingEnvironment::WriteTo
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::GetGrafPort:
- //----------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- GrafPtr TDrawingEnvironment::GetGrafPort()
- {
- return NULL;
- } // TDrawingEnvironment::GetGrafPort
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::Prepare:
- //----------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- void TDrawingEnvironment::Prepare()
- {
- GetPenState(&fSavedPenState);
- GetIfColor(fSavedForegroundColor);
- GetIfBkColor(fSavedBackgroundColor);
- } // TDrawingEnvironment::Prepare
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::Setup:
- //----------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- void TDrawingEnvironment::Setup()
- {
- PenNormal();
- PenSize(fPenSize.h,fPenSize.v);
- PenMode(fPenMode);
- PenPat(&fPenPattern);
- SetIfColor(fForegroundColor);
- SetIfBkColor(fBackgroundColor);
- } // TDrawingEnvironment::Setup
-
- //----------------------------------------------------------------------------------------
- // TDrawingEnvironment::Complete:
- //----------------------------------------------------------------------------------------
- #pragma segment MAViewRes
-
- void TDrawingEnvironment::Complete()
- {
- SetPenState(&fSavedPenState);
- SetIfColor(fSavedForegroundColor);
- SetIfBkColor(fSavedBackgroundColor);
- } // TDrawingEnvironment::Complete
-
- //----------------------------------------------------------------------------------------
- // End of UDrawingEnvironment.cp
-
- #pragma segment Inline
-